package com.guodexian.configmvc;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.MultipartResolver;
import org.springframework.web.multipart.support.StandardServletMultipartResolver;
import org.springframework.web.servlet.ViewResolver;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import org.springframework.web.servlet.view.JstlView;

/**
 * 类说明：<br>
 *
 * @author qfrx<br>
 * 2024/12/24 19:23<br>
 * @since 1.0 <br>
 */
@Configuration
@EnableWebMvc
@ComponentScan("com.guodexian")
public class WebConfig {
    @Bean
    public ViewResolver viewResolver(@Value("${spring.mvc.view.prefix}")String viewPrefix
            , @Value("${spring.mvc.view.suffix}")String suffix) {
        InternalResourceViewResolver viewResolver = new InternalResourceViewResolver();
        viewResolver.setViewClass(JstlView.class);
        viewResolver.setPrefix(viewPrefix);
        viewResolver.setSuffix(suffix);
        return viewResolver;
    }
    @Bean
    public MultipartResolver multipartResolver() {
        return new StandardServletMultipartResolver();
    }
}
